package com.zhenyi.dingke.interceptor;

import javax.servlet.http.HttpServletRequest;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;
import com.utils.AuthUtils;

public class DKAuthIntercetpor implements Interceptor {

	@Override
	public void intercept(Invocation inv) {
		Controller controller = inv.getController();
		controller.setAttr("metaTitleSuffix", "蓁奕科技");
		HttpServletRequest request = controller.getRequest();
		String referer = request.getHeader("Referer");
		controller.setAttr("referer", referer);
		String uid = AuthUtils.getTokenUid(controller);
		if ("lantian".equals(uid)) {
			inv.invoke();
		} else {
			controller.redirect("/dk/admin/login");
		}
	}

}
